<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>补签列表</title>
</head>
<body>

<script type="text/javascript" src="./$.js"></script>
<script>
    require(['!this.js'], $$.load)
</script>
</body>
</html>


<!--tpl部分-->
<template type="text/html" data-name="this.htm">

    <div class="list">
        <div class="weui-search-bar" id="searchBar">
            <form class="weui-search-bar__form">
                <div class="weui-search-bar__box">
                    <i class="weui-icon-search"></i>
                    <input type="search" class="weui-search-bar__input" id="searchInput" placeholder="搜索" required="">
                    <a href="javascript:" class="weui-icon-clear" id="searchClear"></a>
                </div>
                <label class="weui-search-bar__label" id="searchText">
                    <i class="weui-icon-search"></i>
                    <span>搜索姓名/分组</span>
                </label>
            </form>
            <a href="javascript:" class="weui-search-bar__cancel-btn" id="searchCancel">取消</a>
        </div>

        <div class="mylist" v-if="data">
            <div class="mylistItem" v-for="(value,index) in data">
                <div class="title" @click="openTag(value.status,index)">
                    <div v-if="value.a==1">
                        <img src="../$res/imgers/triangle_right.png">
                    </div>
                    <div v-else>
                        <img src="../$res/imgers/triangle_down.png">
                    </div>

                    <span>{{value.name}}</span>
                    <span>{{value.status}}</span>
                </div>

                <div class="mylist_content" v-if="value.a==-1">
                    <a class="mylist_con_item" v-for="info in value.child.list" :href="'detail.html?userid='+info.id">
                        <img :src="info.avatar">
                        <div class="mess">
                            <div class="left">
                                <div class="left_top">
                                    <span>{{info.name}}</span>
                                    <span>{{info.time}}</span>
                                </div>
                                <div class="left_down">
                                    <span>{{info.dept}}</span>
                                    <span>{{info.reason}}</span>
                                </div>
                            </div>
                            <div class="right">查看详情</div>
                        </div>
                    </a>
                </div>
            </div>
        </div>
    </div>

</template>

<!--JS部分-->
<script data-name="this.js">

    function get_list() {
        $$.ajax({
            url: "/kaoqin/apply/supply_count",
            data: {},
            result: {
                $200: function (ret) {
                    for (var i = 0; i < ret.data.length; i++) {
                        ret.data[i].child = false;
                        ret.data[i].a = 1;
                    }
                    $$.m.data = ret.data;
                }
            }
        });
    }

    function opneTag(status, index) {

        if ($$.m.data[index].a == 1 && $$.m.data[index].child == false) {
            weui.loading('加载中');
            $$.ajax({
                url: "/kaoqin/apply/lists_supply",
                data: {
                    type: status
                },
                result: {
                    $200: function (ret) {
                        weui.loading().hide();
                        $$.m.data[index].child = ret.data;
                        $$.m.data[index].a = -$$.m.data[index].a;
                    }
                }
            });
        } else {
            $$.m.data[index].a = -$$.m.data[index].a;
        }
    }

    require('../$res/js/common');
    module.exports = {
        template: require('!this.htm'),
        methods: {
            openTag: opneTag
        },
        loaded: function () {
            weui.loading('加载中');
            $$.m = {
                data: false
            };
        },
        mounted: function () {
            get_list();
            weui.loading().hide();
        }
    };

</script>